/// <reference name="MicrosoftAjax.debug.js" />
/// <reference path="../../Resources/js/jquery/jquery.js" />

Type.registerNamespace("BM");

BM.ValidationError = function(item) {
    /// <summary>
    /// This abstract class serves as a container for information about a validation error
    /// </summary>
    /// <field name="item" type="MItem">
    /// The item that has thrown this validation error
    /// </field>    

    this.item = item;
}

BM.ValidationError.prototype = {
    getErrorText: function() {
        return null;
    },
    
    getItem: function() {
        return this.item;
    }    
}

BM.ValidationError.registerClass("BM.ValidationError", Sys.Component);

BM.ValidationError.go = function(id) {
    var item = MItem.getById(id);
    item.focus();
    return false;
}

// BM.ConstraintValidationError

BM.ConstraintValidationError = function(item, constraint) {
    /// <summary>
    /// This class represents a validation error of a not matched constraint
    /// </summary>
    /// <field name="item" type="MItem">
    /// The item that has thrown this validation error
    /// </field>
    /// <field name="constraint" type="BM.Constraint">
    /// The constraint that did not match
    /// </field>

    BM.ConstraintValidationError.initializeBase(this, [item]);
    this.constraint = constraint;
}

BM.ConstraintValidationError.prototype = {
    getErrorText: function() {
        return this.constraint.getErrorText();
    }
}

BM.ConstraintValidationError.registerClass("BM.ConstraintValidationError", BM.ValidationError);

// BM.NoItemSelectedValidationError

BM.NoItemSelectedValidationError = function(item) {
    /// <summary>
    /// This class represents a validation error when there is no selection in a ChoiceItem.
    /// </summary>
    /// <field name="item" type="ChoiceItem">
    /// The item that has thrown this validation error
    /// </field>

    BM.NoItemSelectedValidationError.initializeBase(this, [item]);
}

BM.NoItemSelectedValidationError.prototype = {
    getErrorText: function() {
        return BM.Messages['NoItemSelected'];
    }
}

BM.NoItemSelectedValidationError.registerClass("BM.NoItemSelectedValidationError", BM.ValidationError);